package org.dtrd.modules.patient.entity.po;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.modules.patient.entity.bean.report.ReportFirst;
import org.dtrd.modules.patient.entity.bean.report.ReportSummary;

import java.util.Date;


/**
 * <p>
 * 患者报告
 * </p>
 *
 * @author QR
 * @since 2022-01-22
 */
@Getter
@Setter
@TableName("dtrd_ent_rd_report")
public class DtrdEntRdReport {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    /**
     * 患者id
     */
    @TableField("patient_id")
    private Integer patientId;

    /**
     * 报告名字
     */
    @TableField("report_name")
    private String reportName;

    /**
     * 患者档案json
     */
    @TableField("patient_archive")
    private String patientArchive;

    /**
     * 患者量表评估json
     */
    @TableField("patient_evaluation")
    private String patientEvaluation;

    /**
     * 患者逆转方案json
     */
    @TableField("patient_reverse_scheme")
    private String patientReverseScheme;

    /**
     * 患者报告单json
     */
    @TableField("patient_archive_report")
    private String patientArchiveReport;

    /**
     * 服务方案json
     */
    @TableField("patient_service_programme")
    private String patientServiceProgramme;

    /**
     * 报告类型: 1-首诊报告, 2-周报, 3-月报, 4-总结报告
     */
    @TableField("report_type")
    private Integer reportType;

    @TableField("create_time")
    private Date createTime;

    @TableField("publish_status")
    private Integer publishStatus;

    @TableField("publish_time")
    private Date publishTime;

    @TableField("publisher")
    public String publisher;

    @TableField("first_evaluate")
    private String firstEvaluate;

    @TableField("summary")
    private String summary;

    @TableField("create_by")
    private String createBy;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    public DtrdEntRdReport init() {
        createTime = new Date();
        isDel = 0;
        publishStatus = 0;
        return this;
    }

    public DtrdEntRdReport parseFromDTO(ReportFirst dto) {
        dataId = dto.getDataId();
        patientId = dto.getPatientId();
        patientArchive = JSONUtil.toJsonStr(dto.getPatientArchive());
        patientEvaluation = JSONUtil.toJsonStr(dto.getPatientEvaluation());
        patientServiceProgramme = JSONUtil.toJsonStr(dto.getPatientServiceProgramme());
        patientArchiveReport = JSONUtil.toJsonStr(dto.getPatientArchiveReport());
        firstEvaluate = JSONUtil.toJsonStr(dto.getFirstEvaluate());
        return this;
    }

    public DtrdEntRdReport parseFromDTO(ReportSummary dto) {
        this.dataId = dto.getDataId();
        this.summary = dto.getSummary();
        this.publishStatus = dto.getPublishStatus();
        this.patientArchive = JSONUtil.toJsonStr(dto.getReportContent());
        return this;
    }


}
